package com.example.hoasbackend.common.utls;

//import jdk.vm.ci.meta.Local;

import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@Component
public class DateTimeUtil {
    public String dateTimetoString(LocalDateTime localDateTime){
        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        String result=df.format(localDateTime);
        return result;
    }
    public LocalDateTime stringtoDateTime(String dateTimeString){
        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        LocalDateTime result=LocalDateTime.parse(dateTimeString,df);
        return result;
    }

    public String timeCheck(LocalDateTime checkInTime, LocalDateTime checkOutTime) {
        LocalDateTime localDateTime=LocalDateTime.now();
        if(localDateTime.compareTo(checkInTime)>0){
            return "check in time too early";
        }
        else if(checkInTime.compareTo(checkOutTime)>0){
            return "check in time too late";
        }else{
            return "";
        }
    }
}

